package com.bhs.sansonglogistics.view;

import android.content.Context;
import android.widget.TextView;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.CompanyReportNum;
import com.bhs.sansonglogistics.utils.DateUtils;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;

import java.util.List;

public class MyMarkerView2  extends MarkerView {

    private TextView tvContent;
    private TextView tvTime;
    private TextView tvMoney;
    private List<CompanyReportNum.DataDTO.OrderListDTO> order_list;

    public MyMarkerView2(Context context, int layoutResource,List<CompanyReportNum.DataDTO.OrderListDTO> order_list) {
        super(context, layoutResource);
        tvTime = findViewById(R.id.tv_time);
        tvContent = findViewById(R.id.tv_number);
        tvMoney=findViewById(R.id.tv_money);
        this.order_list = order_list;
    }

    @Override
    public void refreshContent(Entry e, Highlight highlight) {

        tvTime.setText(DateUtils.getMonthDay(order_list.get((int) e.getX()).getDate()*1000L));
        tvContent.setText(String.format("总单量：%s", (int)e.getY()));
        tvMoney.setText(String.format("总金额：%s", order_list.get((int) e.getX()).getMoney()));

        super.refreshContent(e, highlight);
    }

    @Override
    public MPPointF getOffset() {
        return new MPPointF(-(getWidth() / 2), -getHeight());
    }
}
